<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{padding: 0;margin: 0;}
        .box{
            width: 200px;
            height: 200px;
            background-color: #6ff;
            margin: 50px;
            overflow: hidden;
        }
        .sub{
            width: 100px;
            height: 100px;
            margin: 50px;
            background-color: orange;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="sub"></div>
    </div>
</body>
<script>
    // onclick    鼠标单击 ( 左键  按下并松开)
    // ondblclick 鼠标(左键)双击

    // onmousedown  鼠标按键被按下  (左:0 中:1 右:2 侧键: 3 4)
    // onmouseup    鼠标按键松开
    // onousemove   鼠标移动

    // onmouseover  鼠标划入
    // onmouseout   鼠标移出

    // 问题: 给父元素绑定onmouseover onmouseout事件,鼠标移动到子(代)元素上时也会触发
    // 解决方法: 将onmouseover onmouseout替换为 onmouseenter onmouseleave
    // onmouseenter()   鼠标划入
    // onmouseleave()   鼠标移出


    var box = document.querySelector(".box");

    // // 鼠标移入
    // box.onmouseover = function(){
    //     console.log("鼠标划入");
    // }
    
    // // 鼠标移出
    // box.onmouseout = function(){
    //     console.log("鼠标移出");
    // }


    box.onmouseenter = function(){
        console.log("鼠标划入");
    }
    
    // 鼠标移出
    box.onmouseleave = function(){
        console.log("鼠标移出");
    }






</script>
</html>